package com.mtw.bbs.like.controller.open;



import com.mtw.bbs.common.core.constant.BusinessObjectType;
import com.mtw.bbs.common.core.vo.Result;
import com.mtw.bbs.like.pojo.dto.LikeRecordDto;
import com.mtw.bbs.like.service.LikeRecordService;
import com.mtw.bbs.userAdmin.pojo.vo.UserInfoVo;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 用户点赞接口层
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("open/like")
public class OpenLikeController {


    private final LikeRecordService likeRecordService;



    /**
     * 已赞用户列表
     *
     * @param articleId 文章id
     * @param page      当前页
     * @param size      分页大小
     */
    @GetMapping("/article/list")
    public Result likedArticleUserList(@RequestParam("articleId") String articleId,
                                          @RequestParam(name = "page") int page,
                                          @RequestParam(name = "size") int size) {

        LikeRecordDto dto = new LikeRecordDto();
        dto.setObjectId(articleId);
        dto.setObjectType(BusinessObjectType.ARTICLE);
        List<UserInfoVo> userList = likeRecordService.getUserListForLiked(page, size, dto);
        return Result.success(userList);
    }




    /**
     * 已赞用户列表
     *
     * @param replyId 文章id
     * @param page      当前页
     * @param size      分页大小
     */
    @GetMapping("/reply/list")
    public Result likedReplyUserList(@RequestParam("replyId") String replyId,
                                       @RequestParam(name = "page") int page,
                                       @RequestParam(name = "size") int size) {

        LikeRecordDto dto = new LikeRecordDto();
        dto.setObjectId(replyId);
        dto.setObjectType(BusinessObjectType.REPLY);
        List<UserInfoVo> userList = likeRecordService.getUserListForLiked(page, size, dto);
        return Result.success(userList);
    }





}
